<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script src="../jquery/jquery-1.12.4.min.js"></script>
    访问html页面 要求不跨域
    <!-- <form action="http://localhost:3000/testpost" method="post">
        <input type="text" name="name" id="">
        <input type="text" name="age" id="">
        <button type="submit">发送</button>
    </form> -->
    <button class="testpost">testpost</button>
    <button class="testget">testget</button>
    <script>
        console.log($);
        // 绑定事件发送请求
        $('.testpost').click(()=>{
            console.log('jquery中绑定事件')
            $.ajax({
                method:'post',
                url:'http://localhost:3000/testpost',
                data:{
                    name:'tom',
                    age:100
                },
                success:(data)=>{
                    console.log(data);
                },
                error:(err)=>{
                    console.log(err);
                }
            })
        })
    </script>
</body>
</html>